#include <Game\Include\DistributionLogic.h>


DistributionLogic::DistributionLogic(Channel* comm_channel, SyncQueue* output_queue)
{
    this->comm_channel = comm_channel;
    this->output_queue = output_queue;
    this->channel_receiver_task = NULL;    
}

DistributionLogic::~DistributionLogic(void)
{
}

void DistributionLogic::channel_receiver_task_function(void* user_data)
{
    ChannelReceiverTaskData* data = reinterpret_cast<ChannelReceiverTaskData*>(user_data);
    SimpleMessage* simple_message = NULL;
    try
    {
        simple_message = data->channel->receive();
        data->output_queue->push(simple_message);
    }
    catch (ChannelExceptionType e)
    {
        data->channel_receiver_task->stop();
    	delete data;        
    }    
}
